<%@ page language="java" contentType="text/html;" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<style type="text/css">
.list_wrap{
    list-style: none;
    margin-top: 10px;
    padding-left: 10px;
    background-color: #F5F5F5;
}
.list_wrap li{
    padding: 8px;
}
.area_cancellation{
    margin-top: 10px;
    padding-left: 10px;	
    text-align: center;
}
.btn_blue{
	border: none;
	border-radius: 5px;
	background-color: #009ACD;
	color: #FFFFFF;
	height: 30px;
	padding:5px 20px;
	margin-top: 20px;
	font-weight: bold;
	text-decoration:none;
}	
</style>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true" >
				<ul class="list_wrap">
					<li>采购商： <span id="buyer"></span></li>
					<li>下单时间： <span id="bookingTime"></span></li>
					<li>&nbsp;</li>
					<li>应收金额： <span id="arAmount"></span></li>
					<li>业务状态： <span id="bizStatus"></span></li>
					<li>财务状态： <span id="payStatus"></span> </li>
				</ul>
				<div class="area_cancellation">
				备注：<textarea id="m" rows="4" cols="20" style="width:85%;"></textarea><br>
				<input type="button" onclick="cancelOrder();" class="btn_blue" value="确 定">
				</div>
	</div>

<script type="text/javascript">
function initPage(b){
	if(b==null){
		layer.alert("订单【${orderNumber}】不存在!");
		parent.layer.close(parent.layer.getFrameIndex(window.name));
		return;
	}
	$("#buyer").text(b.purchase);
	$("#bookingTime").text(b.createTimeStr);
	$("#arAmount").text(CommonConverter.formatMoney(b.unitPrice*b.purchQuantity));
	$("#bizStatus").text(CommonConverter.toOrderBizStatusStr(b.orderStatus));
	$("#payStatus").text(CommonConverter.toOrderPayStatusStr(b.financeStatus));
}

function cancelOrder(){
	progressLoad();
	$.ajax({
		type:'get',
		url: '${ctx}/order/cancel/${orderNumber}?t='+Math.random(),
		data: 'remarks='+$("#m").val(),
		dataType: 'json',
		success:function(data){
			progressClose();
			if(data.status==1){
				layer.alert('取消订单成功！',{skin:'layui-layer-lan',title: ['系统提示', 'background-color:#00B2EE; color:#fff;'],closeBtn: 0}, function(index){
					parent.location.reload();
					parent.layer.close(parent.layer.getFrameIndex(window.name));
					layer.close(index);
				});
			}
			else{
				layer.alert(data.message);
			}
		},
		error:function(msg){
			progressClose();
			layer.alert("请检查您的网络连接，然后重试！");
		}
	}); 
}; 
$(function(){
	$.ajax({
		type:'get',
		url:'${ctx}/nporder/orderDetail/${orderNumber}',
		contentType:'application/json;charset=utf-8',
		dataType:'json',
		async:false,
		success:function(data){
			if(data.success){
				initPage(data.obj);
				return;
			}
			else{
				layer.alert(data.msg);
			}
		},
		error:function(msg){
			layer.alert("请检查您的网络连接，然后重试！");
		}
	}); 
});
</script>

</body>
</html>